#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = 998244353;

signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a.begin() + 1, a.end());
	int x = 0;
	for (int i = 1; i <= n; i++) {
		x = x * 10 + a[i];
		x = x % MOD;
	}
	cout << x % MOD << endl;
	return 0;
}